include(ECMQmlModule)

if (QT_MAJOR_VERSION STREQUAL "6")

    ecm_add_qml_module(kritaqmlcomponents
        URI "org.krita.components"
        VERSION 1.0
        SHARED
        GENERATE_PLUGIN_SOURCE
    )

    target_sources(kritaqmlcomponents
        PRIVATE
            SvgTextLabel.cpp
            SvgTextLabel.h
            KisNumParser.cpp
            KisNumParser.h
            KisCubicCurveQMLWrapper.cpp
            KisCubicCurveQMLWrapper.h
            KisTheme.cpp
            KisTheme.h
            KisFontFunctions.cpp
            KisFontFunctions.h
            KoShapeQtQuickLabel.cpp
            KoShapeQtQuickLabel.h
            TagFilterProxyModelQmlWrapper.cpp
            TagFilterProxyModelQmlWrapper.h
    )

else ()
    ecm_add_qml_module(kritaqmlcomponents
        URI "org.krita.components"
        VERSION 1.0
        CLASSNAME KritaQmlComponentsPlugin
    )

    target_sources(kritaqmlcomponents
        PRIVATE
            KritaQmlComponentsPlugin.cpp
            KritaQmlComponentsPlugin.h
            SvgTextLabel.cpp
            SvgTextLabel.h
            KisNumParser.cpp
            KisNumParser.h
            KisCubicCurveQMLWrapper.cpp
            KisCubicCurveQMLWrapper.h
            KisTheme.cpp
            KisTheme.h
            KisFontFunctions.cpp
            KisFontFunctions.h
            KoShapeQtQuickLabel.cpp
            KoShapeQtQuickLabel.h
            TagFilterProxyModelQmlWrapper.cpp
            TagFilterProxyModelQmlWrapper.h
    )

endif ()

ecm_target_qml_sources(kritaqmlcomponents PRIVATE PATH textinput SOURCES
    qml/textinput/TextInputWithSelectionRange.qml
    qml/textinput/TextInputWithPrefixAndSuffix.qml
)

ecm_target_qml_sources(kritaqmlcomponents PRIVATE PATH overlays SOURCES
    qml/overlays/WarningOverlay.qml
    qml/overlays/SliderOverlay.qml
)

ecm_target_qml_sources(kritaqmlcomponents PRIVATE PATH spinbox SOURCES
    qml/spinbox/ParseSpinBoxContentItem.qml
)

ecm_target_qml_sources(kritaqmlcomponents PRIVATE PATH sliderspinbox SOURCES
    qml/sliderspinbox/SliderSpinBoxManipulator.qml
    qml/sliderspinbox/SliderSpinBoxRangeSwitch.qml
    qml/sliderspinbox/SliderSpinBoxContentItem.qml
)

ecm_target_qml_sources(kritaqmlcomponents PRIVATE PATH angleselector SOURCES
    qml/angleselector/AngleSelectorUtil.js
    qml/angleselector/AngleGauge.qml
)

ecm_target_qml_sources(kritaqmlcomponents PRIVATE PATH +Fusion SOURCES
    qml/themedComponents/+Fusion/TabButtonBase.qml
    qml/themedComponents/+Fusion/ToolSeparatorBase.qml
)

ecm_target_qml_sources(kritaqmlcomponents PRIVATE PATH +qt5 SOURCES
    qml/+qt5/WindowFocusChecker.qml
)

ecm_target_qml_sources(kritaqmlcomponents SOURCES
    qml/button/GroupButton.qml
    qml/button/OptionButtonStrip.qml

    qml/ThemedControl.qml
    qml/IntParseSpinBox.qml
    qml/DoubleSpinBox.qml
    qml/DoubleParseSpinBox.qml

    qml/IntSliderSpinBox.qml
    qml/DoubleSliderSpinBox.qml

    qml/themedComponents/ToolTipBase.qml
    qml/themedComponents/TabButtonBase.qml
    qml/themedComponents/ToolSeparatorBase.qml

    qml/curvewidget/CurveWidget.qml

    qml/AngleSelector.qml
    qml/InformingTextInput.qml

    qml/WindowFocusChecker.qml

    qml/ResourceView.qml
    qml/ResourcePopup.qml
    qml/resourceDelegates/ResourceDelegateBase.qml
    qml/resourceDelegates/FontFamilyDelegate.qml
    qml/resourceDelegates/CssStylePresetDelegate.qml

)
if (QT_MAJOR_VERSION STREQUAL "6")
    target_link_libraries(kritaqmlcomponents
        PRIVATE
        kritaui
        Qt::Qml
        Qt::Quick
        Qt::QuickControls2
        KF${KF_MAJOR}::ColorScheme
    )
else ()
    target_link_libraries(kritaqmlcomponents
        PRIVATE
        kritaui
        Qt::Qml
        Qt::Quick
        Qt::QuickControls2
    )
endif ()

ecm_finalize_qml_module(kritaqmlcomponents DESTINATION ${KDE_INSTALL_QMLDIR})

# Note: we don't need ecm_generate_qmltypes, in Qt6 it is autogenerated
# by ecm_finalize_qml_module

# Note: the ecm documentation prescribes this line but it is not needed,
# since all the installation work is done by ecm_finalize_qml_module
#
# install(TARGETS kritaqmlcomponents ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})



